package com.turtle.security.security.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

/**
 * 认证用户信息
 *
 * @author turtle
 * date: 2020-05-09
 */
@Data
public class AuthUserDTO implements UserDetails {


    /**
     * 登录用户密钥，用户存储redis
     */
    @JsonIgnore
    private String userKey;
    /**
     * token过期时间
     */
    @JsonIgnore
    private Long expireTime;
    /**
     * 用户认证时间
     */
    @JsonIgnore
    private Long loginTime;
    /**
     * 用户id
     */
    private Integer userId;
    /**
     * 用户账号
     */
    private String userName;
    /**
     * 登录密码
     */
    @JsonIgnore
    private String password;

    public AuthUserDTO() {
    }


    @Override
    @JsonIgnore
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    @JsonIgnore
    public String getPassword() {
        return this.password;
    }

    @Override
    @JsonIgnore
    public String getUsername() {
        return this.userName;
    }

    @Override
    @JsonIgnore
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    @JsonIgnore
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    @JsonIgnore
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    @JsonIgnore
    public boolean isEnabled() {
        return true;
    }
}
